<template>
  <div class="container">
    <Navbar />
    
    <!-- 英雄区域 -->
    <div class="hero-section">
      <div class="hero-content">
        <h1>探索QQ飞车的精彩世界</h1>
        <p>浏览所有赛车和宠物的详细数据，找到最适合你的搭配，提升你的竞技水平。</p>
        <button @click="$router.push('/car-list')">开始探索 <font-awesome-icon :icon="['fas', 'arrow-right']" /></button>
      </div>
    </div>
    
    <!-- 热门赛车 -->
    <div class="featured-section">
      <div class="section-header">
        <h2><font-awesome-icon :icon="['fas', 'fire']" /> 热门赛车</h2>
        <router-link to="/car-list" class="view-all">查看全部 <font-awesome-icon :icon="['fas', 'angle-right']" /></router-link>
      </div>
      <div class="card-grid">
        <div v-for="(car, index) in hotCars" :key="index" class="card">
          <div class="card-img" :style="{ backgroundColor: car.bgColor }">
            <div class="card-badge">{{ car.level }}</div>
          </div>
          <div class="card-content">
            <div class="card-title">{{ car.name }}</div>
            <div class="card-meta">
              <div class="card-type">{{ car.type }}</div>
              <div class="card-rating">
                <font-awesome-icon :icon="['fas', 'star']" />
                <span>{{ car.rating }} ({{ car.ratingCount }})</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <!-- 热门宠物 -->
    <div class="featured-section">
      <div class="section-header">
        <h2><font-awesome-icon :icon="['fas', 'paw']" /> 热门宠物</h2>
        <router-link to="/pet-list" class="view-all">查看全部 <font-awesome-icon :icon="['fas', 'angle-right']" /></router-link>
      </div>
      <div class="card-grid">
        <div v-for="(pet, index) in hotPets" :key="index" class="card">
          <div class="card-img" :style="{ backgroundColor: pet.bgColor }">
            <div class="card-badge">{{ pet.rarity }}</div>
          </div>
          <div class="card-content">
            <div class="card-title">{{ pet.name }}</div>
            <div class="card-meta">
              <div class="card-type">{{ pet.type }}</div>
              <div class="card-rating">
                <font-awesome-icon :icon="['fas', 'star']" />
                <span>{{ pet.rating }} ({{ pet.ratingCount }})</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <!-- 最新攻略 -->
    <div class="featured-section">
      <div class="section-header">
        <h2><font-awesome-icon :icon="['fas', 'book']" /> 最新攻略</h2>
        <a href="#" class="view-all">查看全部 <font-awesome-icon :icon="['fas', 'angle-right']" /></a>
      </div>
      <div class="card-grid">
        <div v-for="(guide, index) in guides" :key="index" class="card">
          <div class="card-img" :style="{ backgroundColor: guide.bgColor }">
            <div class="card-badge">{{ guide.type }}</div>
          </div>
          <div class="card-content">
            <div class="card-title">{{ guide.title }}</div>
            <div class="card-meta">
              <div class="card-type">{{ guide.author }}</div>
              <div class="card-rating">
                <font-awesome-icon :icon="['fas', 'eye']" />
                <span>{{ guide.views }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
/**
 * 首页组件
 * @component Home
 */
import { ref } from 'vue'
import Navbar from '../components/Navbar.vue'

// 热门赛车数据
const hotCars = ref([
  { name: '雷诺特技车', type: 'A车', level: 'S级', rating: '4.9', ratingCount: '120', bgColor: '#3a8bff' },
  { name: '流星', type: 'B车', level: 'A级', rating: '4.7', ratingCount: '98', bgColor: '#ff6b6b' },
  { name: '剃刀', type: 'A车', level: 'A级', rating: '4.6', ratingCount: '87', bgColor: '#20c997' },
  { name: '魔鲨', type: 'B车', level: 'B级', rating: '4.5', ratingCount: '76', bgColor: '#6f42c1' }
])

// 热门宠物数据
const hotPets = ref([
  { name: '小白龙', type: '辅助型', rarity: '传说', rating: '4.9', ratingCount: '135', bgColor: '#fd7e14' },
  { name: '幻想猫', type: '攻击型', rarity: '稀有', rating: '4.8', ratingCount: '112', bgColor: '#0dcaf0' },
  { name: '机械龟', type: '防御型', rarity: '普通', rating: '4.6', ratingCount: '89', bgColor: '#20c997' },
  { name: '幻翼天马', type: '速度型', rarity: '稀有', rating: '4.7', ratingCount: '104', bgColor: '#e83e8c' }
])

// 攻略数据
const guides = ref([
  { title: '赛道弯道技巧详解', type: '技巧', author: '官方', views: '2.3万', bgColor: '#6610f2' },
  { title: '最佳赛车与宠物搭配指南', type: '搭配', author: '玩家', views: '1.8万', bgColor: '#fd7e14' }
])
</script>

<style scoped>
.hero-section {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
}

.hero-content {
  flex: 1;
  padding: 30px;
  background: linear-gradient(135deg, #ff6b6b 0%, #ff9e9e 100%);
  border-radius: 10px;
  color: white;
}

.hero-content h1 {
  font-size: 32px;
  margin-bottom: 15px;
}

.hero-content p {
  font-size: 16px;
  margin-bottom: 20px;
  opacity: 0.9;
}

.hero-content button {
  background: white;
  color: #ff6b6b;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.3s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.hero-content button:hover {
  transform: translateY(-3px);
}

.featured-section {
  margin-bottom: 30px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.section-header h2 {
  font-size: 20px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-all {
  color: #0078ff;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.view-all i {
  margin-left: 5px;
}

.card-img {
  height: 150px;
  position: relative;
}

.card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
}

.card-content {
  padding: 15px;
}

.card-title {
  font-size: 16px;
  margin-bottom: 5px;
  font-weight: bold;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #666;
}

.card-rating {
  color: #ff9800;
  display: flex;
  align-items: center;
}

.card-rating span {
  margin-left: 5px;
}

@media (max-width: 768px) {
  .hero-section {
    flex-direction: column;
  }
}
</style> 